package com.stxx.assistant.service.impl;

import cn.hutool.core.util.ReflectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.script.ScriptUtil;
import com.stxx.assistant.domain.SysTask;
import com.stxx.assistant.framwork.constants.DataType;
import com.stxx.assistant.framwork.domain.model.PageQuery;
import com.stxx.assistant.framwork.domain.model.PageResult;
import com.stxx.assistant.framwork.utils.StoreUtils;
import com.stxx.assistant.service.SysTaskService;
import org.noear.solon.annotation.Component;
import org.noear.solon.annotation.Init;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author Fuzhenlei
 * @date 2025/01/17 12:23
 */
@Component
public class SysTaskServiceImpl implements SysTaskService {


    @Override
    public int insert(SysTask bean) throws SQLException {
        return StoreUtils.insert(bean);
    }

    @Override
    public int update(SysTask bean) throws SQLException {
        return StoreUtils.update(bean, SysTask::getId);
    }


    @Override
    public int delete(String id) throws SQLException {
        return StoreUtils.delete(SysTask.class, SysTask::getId,id);
    }

    @Override
    public int deleteByIds(String[] ids) throws SQLException {
        return StoreUtils.deleteByIds(SysTask.class, SysTask::getId,ids);
    }

    @Override
    public List<SysTask> list(SysTask obj) throws SQLException {
        return StoreUtils.selectList(SysTask.class,obj);
    }

    @Override
    public PageResult<SysTask> pageList(SysTask obj, PageQuery pageQuery) throws SQLException {
        return StoreUtils.selectPageList(SysTask.class,obj,pageQuery);
    }

    @Override
    public int deleteBefore(Date endDate) throws SQLException {
        return StoreUtils.sql("delete from sys_task where create_time < ?",endDate).update();
    }

}
